home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11094 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: newsbf02.news.aol.com!not-for-mail
  2. From: hafshar@aol.com (HAfshar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Help - problem with fstream and random-access files
  5. Date: 12 Mar 1996 12:54:03 -0500
  6. Organization: America Online, Inc. (1-800-827-6364)
  7. Sender: root@newsbf02.news.aol.com
  8. Message-ID: <4i4dnr$ld2@newsbf02.news.aol.com>
  9. Reply-To: hafshar@aol.com (HAfshar)
  10. NNTP-Posting-Host: newsbf02.mail.aol.com
  11.  
  12. Hello,
  13.  
  14. I'm trying to create a random-access file of fixed-length records.  Each
  15. record (struct) has a couple of integers and a couple of arrays of
  16. characters.  I initialize the file with zero for each field, since the
  17. number of records in the file is fixed and I would like to return zero for
  18. access to a record that has not yet been written.
  19.  
  20. I start out writing records to the file and everything seems okay but when
  21. I try to read back the records and print them to the screen or to a file,
  22. the first 9 read back unexpected values (but formatted correctly).  After
  23. that, the 10th record seems to be corrupted, and then the file seems to
  24. get back in synch again.
  25.  
  26. I stepped the program through a debugger and noticed that the get and put
  27. file pointers seem to be at an unexpected location (for example I expect
  28. the next record to be at address 0x400 but "tellg" tells me that it is
  29. actually at 0x402.  
  30.  
  31. Does anyone have any ideas?
  32.  
  33. Thanks,
  34.  
  35. Harry
  36. PS> I'm using Borland v4.02  
  37.